package com.papercutting.platform.dto.response;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 教程响应信息
 */
@Data
public class TutorialResponse implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    private Long id;
    private String title;
    private String subtitle;
    private String coverImage;
    private String summary;
    private String content;
    private String videoUrl;
    private Integer videoDuration;
    private Integer difficultyLevel;
    private String difficultyLevelText;
    private Integer category;
    private String categoryText;
    private String tags;
    private String toolsRequired;
    private String materialsRequired;
    private Integer stepsCount;
    private Integer estimatedTime;
    private Integer viewCount;
    private Integer likeCount;
    private Integer favoriteCount;
    private Integer studyCount;
    private Integer sortOrder;
    private Integer status;
    private String statusText;
    private Boolean isRecommend;
    private Boolean isFree;
    private Long creatorId;
    private String creatorName;
    
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;
    
    public void setDifficultyLevel(Integer difficultyLevel) {
        this.difficultyLevel = difficultyLevel;
        if (difficultyLevel != null) {
            switch (difficultyLevel) {
                case 1: this.difficultyLevelText = "初级"; break;
                case 2: this.difficultyLevelText = "中级"; break;
                case 3: this.difficultyLevelText = "高级"; break;
                default: this.difficultyLevelText = "未知"; break;
            }
        }
    }
    
    public void setCategory(Integer category) {
        this.category = category;
        if (category != null) {
            switch (category) {
                case 1: this.categoryText = "基础入门"; break;
                case 2: this.categoryText = "进阶技法"; break;
                case 3: this.categoryText = "高级创作"; break;
                default: this.categoryText = "未知分类"; break;
            }
        }
    }
    
    public void setStatus(Integer status) {
        this.status = status;
        if (status != null) {
            switch (status) {
                case 0: this.statusText = "草稿"; break;
                case 1: this.statusText = "已发布"; break;
                case 2: this.statusText = "已下架"; break;
                default: this.statusText = "未知状态"; break;
            }
        }
    }
}